package org.tacademy.layoutinflation;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;

public class MyLayoutInflationActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        LinearLayout buttonLayout = (LinearLayout)findViewById(R.id.buttonLayout);
        
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.button, buttonLayout, true);
        
        final CheckBox allDay = (CheckBox)findViewById(R.id.allDay);
        Button btnSelect = (Button)findViewById(R.id.selectBtn);
        btnSelect.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(allDay.isChecked()){
					allDay.setChecked(false);
				}
				else
					allDay.setChecked(true);
			}
		});
    }
}